<?php
/**
 * Created by PhpStorm.
 * User: l
 * Date: 2016/7/18
 * Time: 15:18
 */
use app\assets\AppAsset;
use yii\widgets\ActiveForm;
use yii\helpers\Html;
AppAsset::register($this);

$base = Yii::$app->request->baseUrl;
AppAsset::addCss($this, $base . "/css/login.css");
$this->title = '登录';

?>
<div class="login">
    <?php $form = ActiveForm::begin([
        'id' => 'login-form',
        'options' => ['class' => 'form-horizontal'],
        'fieldConfig' => [
            'template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>",
            'labelOptions' => ['class' => 'col-lg-1 control-label'],
        ],
    ]); ?>
    <?= $form->field($model, 'username')->textInput(['autofocus' => true, 'placeholder' => "请输入用户名或者手机号"]) ?>
    <?= $form->field($model, 'password')->passwordInput(['placeholder' => "请输入密码"]) ?>
    <a href="../reset-pwd/step1" style="float: right;padding-right: 5%;" >忘记密码?</a>
    <div class="login-btn">
        <?= Html::submitButton('登录', ['class' => 'submit', 'type' => 'button']) ?>
        <div class="login-reg" onclick="goToRegister()"><p>注册</p></div>
    </div>
    <?php ActiveForm::end(); ?>

</div>

<script>
    function goToRegister() {
        location.href = ('register');
    }

    function GetRequest() {
        var url = location.search; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for(var i = 0; i < strs.length; i ++) {
                theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    }
    var Request=GetRequest();
    var type=Request['type'];
    if(type==2){
        alert("无法用管理员账号进行登录!!");
    }


</script>